package com.timoon.webcomponent.utility.navs.nav1;

import java.util.List;

import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.markup.html.link.BookmarkablePageLink;
import org.apache.wicket.markup.html.list.ListItem;
import org.apache.wicket.markup.html.list.ListView;

import com.timoon.component.behavior.nav.nav1.Nav1Behavior;
import com.timoon.webcomponent.utility.navs.AbstractNavsPanel;

/**
 *<p>主导航,最大与最佳为7个</p>
 *<p>public</p>
 *<p>Copyright:Copyright(c)2013.4.1</p>
 *<p>Company:timoon</p>
 *@author 付乐天
 *@version 1.0 */
public class Nav1Panel extends AbstractNavsPanel {

	private List<Nav1Parameter> parameters;
	
	public Nav1Panel(String id,List<Nav1Parameter> parameters) {
		super(id);
		// TODO Auto-generated constructor stub
		
		this.parameters=parameters;
		
		renderPanel();
		
		this.add(new Nav1Behavior("#menu2"));
	}

	private void renderPanel() {
		// TODO Auto-generated method stub
		
		renderLink();
	}

	private void renderLink() {
		// TODO Auto-generated method stub		
		ListView<Nav1Parameter> listView=new ListView<Nav1Parameter>("wk_list",this.parameters) {
			
			@Override
			protected void populateItem(ListItem<Nav1Parameter> arg0) {
				// TODO Auto-generated method stub
				Nav1Parameter p=arg0.getModelObject();
				
				BookmarkablePageLink link=new BookmarkablePageLink("wk_link",p.getTargetPage());
				link.add(new Label("wk_label",p.getLabel()));
				arg0.add(link);
			}
		};
		add(listView);
	}

}
